<?php
namespace common\records;
use Yii;
use yii\db\ActiveRecord;
use common\records\Toy;

class Record extends ActiveRecord
{
    /**
    ** @return string 返回该AR类关联的数据表名
    **/
    public static function tableName()
    {
        return 'record';
    }

    public function rules()
    {
        return [
            [['uid','coin','timestamp'],'required'],
            [['uid','machine_id','description'],'string'],
            [['coin','type','status','toy_id'],'integer'],
            ];
    }

    public function getUser()
    {
        return $this->hasOne(\common\records\UserInfo::className(), ['uid' => 'uid']);
    }

    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => '用户ID',
            'toy_id' => '娃娃ID',
            'toy_name' => '娃娃名',
            'machine_id' => '娃娃机ID',
            'order_id' => '订单ID',
            'coin' => '娃娃币',
            'description' => '描述',
            'status' => '状态',
            'timestamp' => '添加时间',
            ];
    }

}
